﻿#ifndef BGAPACKAGEMANAGER_H
#define BGAPACKAGEMANAGER_H

#include "singleton.h"
#include <QDebug>
#include <QSettings>
#include <QCoreApplication>
#include "staticfunction.h"
class BgaPackageManager: public Singleton<BgaPackageManager>
{
public:

	typedef struct _POD_INFO {
		QList<QPointF> ballsPosList;
		QList<QPointF> capsPosList;
		double meanCapArea;
		double meanShadowRatio;
		double minShadowRatio;
		double maxShadowRatio;
		QPointF ballsCenter;
		double ballsPhi;
		double rectWidth;
		double rectHeight;
		QPointF capsCenter;
	}POD_INFO;



	typedef struct _INSPECT_PARAM {
		bool bBypass;
		bool bBallDamaged;
		bool bChipping;
		bool bCapDamaged;
		bool bResultCali;
		bool bKeepImageRatio;
		bool bOnlySaveFail;
		bool bSeperateFolder;
		bool bShowNumLabel;
		int iCountForSeperateFolder;
		int miniDamagedRatio;
		int miniChippingArea;
		int miniCircularity;
		int miniAreaRatio;
		int maxAreaRatio;
		int miniDamagedContLength;
		int miniCrescentArea;
		int saveDays;
	}INSPECT_PARAM;

   
	void SavePodToFile(POD_INFO p);
	BgaPackageManager::POD_INFO GetPodFromFile();

	void SaveParamToFile(INSPECT_PARAM param);
	INSPECT_PARAM GetParamFromFile();
	//void SetPackageType(QString type)
	//{
	//	qDebug() << "SetPackageType:" << type;
	//	m_type = type;
	//}

	QString GetPackageType()
	{
		QString appName = QCoreApplication::applicationName();
		QSettings app(appName, "Config");
		m_type = app.value("Package").toString();
		//app.setValue("Package", ui->comboBox->currentText());
		return m_type;
	}

protected:
    QString m_type;
    friend class Singleton<BgaPackageManager>;
    BgaPackageManager();
};

#endif // BGAPACKAGEMANAGER_H
